#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    setWindowTitle("ANIMAIL_TEST");

    ui->label->setPixmap(QPixmap("6.jpg"));

    //设置动画
    animation = new QPropertyAnimation;
    animation->setTargetObject(ui->label);
    animation->setPropertyName("size");
    animation->setStartValue(QSize(0,0));
    animation->setKeyValueAt(0.5,QSize(50,50));
    animation->setEndValue(QSize(700,600));
    animation->setDuration(4000);
    connect(animation,SIGNAL(finished()),this,SLOT(slotAnmationFinished()));
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    if(ui->pushButton->text() == "start")
    {
        animation->start();
        ui->pushButton->setText("pause");
    }
    else if(ui->pushButton->text() == "pause")
    {
        animation->stop();
        ui->pushButton->setText("continue");
    }
    else if(ui->pushButton->text() == "continue")
    {
        animation->resume();
        ui->pushButton->setText("pause");
    }
}

void Widget::on_pushButton_2_clicked()
{
    animation->stop();
    ui->pushButton->setText("start");
}
